<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/babel">
    class Weather extends React. Component {
        // 类中的赋值语句，会添加到实例对象上
        state = {
            isHot: true,
        };
        wind = '中风';

        render() { 
            return <h1 onClick={this.changeWeather}>今天天气{this.state.isHot?'热': '凉'}</h1>
        }
        
        // 自定义方法
        changeWeather = () =>{
            const {isHot} = this.state; // this指向函数外部的实例对象
            this.setState({
                isHot: !isHot
            })
        }
    }
    ReactDOM.render(<Weather />, document.getElementById('app'))
    </script>

</body>
</html>